﻿
//      销售排行
//         $(function() {
//             // Accordion
//             $("#accordion").accordion({ header: "h3" });
//         });
         $(function() {
             $("#accordion").accordion({
                 event: "mouseover"
             });
         });


//      游戏排行
//         $(function() {
//             // Accordion
//             $("#accordion2").accordion({ header: "h3" });
//         });

         $(function() {
             $("#accordion2").accordion({
                 event: "mouseover"
             });
         });
         
//        特价促销
         $(document).ready(function() {
             $("#infoPrevLink").click(function() {
                 $("#infoList").show(500);
                 $("#infoList2").hide(500);
                 $(this).addClass("prev").removeClass("prev2");
                 $("#infoNextLink").addClass("next").removeClass("next2");

             });


             $("#infoNextLink").click(function() {
                 $("#infoList").hide(500);
                 $("#infoList2").show(500);
                 $(this).addClass("next2").removeClass("next");
                 $("#infoPrevLink").addClass("prev2").removeClass("prev");

             });

             //            全球代购
             $("#KeyWord").focus(function() {
                 $(".global_tishi_CrawlPromt").addClass("blue").text(" 输入所有中国购物网站的商品链接地址就可以代购!");
                 if ($("#KeyWord").val() == "http://") {
                     $("#KeyWord").val("");
                 }
             });
             $("#KeyWord").blur(function() {
                 $(".global_tishi_CrawlPromt").removeClass("blue");
                 if ($.trim($("#KeyWord").val()).length <= 0) {
                     $("#KeyWord").val("http://");
                 }
             });
             var f = function() {
                 var d = $.trim($("#KeyWord").val());
                 if (d.length <= 0 || d == "http://") {
                     $(".global_tishi_CrawlPromt").addClass("crawl_red").text("请您输入商品链接地址！");
                     return false;
                 }
                 var j = new RegExp("http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?");
                 if (d.indexOf("http://") < 0 && d.indexOf("https://") < 0) {
                     d = "http://" + d;
                 }
                 if (!j.test(d)) {
                     $(".global_tishi_CrawlPromt").addClass("crawl_red").text("您输入的链接地址不正确，请核实后再填写！");
                     return false;
                 }
                 $("#KeyWord").val(""); window.Panli.Crawl.open(d);
                 return false;
             };
             $("#KeyWord").keydown(function(d) {
                 if (d.keyCode == 13) {
                     f();
                     return false;
                 }
             });
             $("#globalSubmitBtn").click(f);
             //         全部分类
             //Default Action 
             $(".tab_content").hide(); //Hide all content
             $("ul.tabs li:first").addClass("c").show(); //Activate first tab 
             $(".tab_content:first").show(); //Show first tab content 
             //On Click Event 
             $("ul.tabs li").click(function() {
                 $("ul.tabs li").removeClass("c"); //Remove any "active" class 
                 $(this).addClass("c"); //Add "active" class to selected tab 
                 $(".tab_content").hide(); //Hide all tab content 
                 var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
                 $(activeTab).fadeIn(); //Fade in the active content 
                 return false;
             });

             
             //         二列卡片切换
             //Default Action 
             $(".tab2_content").hide(); //Hide all content
             $("ul.tabs li:first").addClass("c").show(); //Activate first tab 
             $(".tab2_content:first").show(); //Show first tab content 
             //On Click Event 
             $("ul.tabs li").click(function () {
                 $("ul.tabs li").removeClass("c"); //Remove any "active" class 
                 $(this).addClass("c"); //Add "active" class to selected tab 
                 $(".tab2_content").hide(); //Hide all tab content 
                 var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content 
                 $(activeTab).show(); //Fade in the active content 
                 return false;
             });


//             $("select.products_name_chose").bind("change", function(e) {
//                 var value;
//                 switch ($(this).find("option:selected").text()) {
//                     case "美元": value = "美元"; break;
//                     case "加元": value = "加元"; break;
//                     case "英磅": value = "英磅"; break;
//                     case "欧元": value = "欧元"; break;
//                     case "日元": value = "日元"; break;
//                     case "澳元": value = "澳元"; break;
//                     case "新元": value = "新元"; break;
//                     case "人民币": value = "人民币"; break;
//                 }
//                 var chose_uu = $(this).attr("uu");
//                 if (chose_uu == "chose1") {
//                     $("span.products_arrow_price1").text("" + value);
//                 }
//                 else if (chose_uu == "chose2") {
//                     $("span.products_arrow_price2").text("" + value);
//                 }
//                 //             北京时间
//                 
//                 var a = new Date(parseInt($("#Beijing_Time").val()));

//                 a.setMinutes(a.getMinutes() + a.getTimezoneOffset());
//                 setInterval(function() {
//                     a.setSeconds(a.getSeconds() + 1);
//                     $("#BeijingDate").html("北京时间：" + a.getFullYear() + "-" + (a.getMonth() < 9 ? "0" : "") + (a.getMonth() + 1) + "-" + (a.getDate() < 9 ? "0" : "") + a.getDate());
//                     $("#BeijingTime").html("<span>" + a.getHours() + "</span><b></b><span>" + (a.getMinutes() < 10 ? "0" : "") + a.getMinutes() + "</span><b></b><span>" + (a.getSeconds() < 10 ? "0" : "") + a.getSeconds() + "</span>");
//                 }, 1000);

//             });


             //              button
//             $(".products_arrow_ui1").mouseover(function() {
//                 $(this).addClass("products_arrow_ui1_2");
//             });

//             $(".products_arrow_ui1").mouseout(function() {
//                 $(this).removeClass("products_arrow_ui1_2");

//             });
//             $(".products_arrow_ui2").mouseover(function() {
//                 $(this).addClass("products_arrow_ui2_2");
//             });

//             $(".products_arrow_ui2").mouseout(function() {
//                 $(this).removeClass("products_arrow_ui2_2");

//             });
//             $(".products_arrow_ui3").mouseover(function() {
//                 $(this).addClass("products_arrow_ui3_2");
//             });

//             $(".products_arrow_ui3").mouseout(function() {
//                 $(this).removeClass("products_arrow_ui3_2");

//             });
             $(".join_position").mouseover(function() {
                 $(this).addClass("join_position_2");
             });

             $(".join_position").mouseout(function() {
                 $(this).removeClass("join_position_2");

             });
             $(".submit_position").mouseover(function() {
                 $(this).addClass("submit_position_2");
             });

             $(".submit_position").mouseout(function() {
                 $(this).removeClass("submit_position_2");

             });

             $(".hot_game_area_item").mouseover(function() {
                 $(this).addClass("hot_game_area_item_2");
             });

             $(".hot_game_area_item").mouseout(function () {
             
                 $(this).removeClass("hot_game_area_item_2");
             });




             $(".register_button").mouseover(function () {
                 $(this).addClass("register_button_");
             });
             
              $(".register_button").mouseout(function () {

                 $(this).removeClass("register_button_");
             });



         });

         //^^^^^^^^^^^^^^^^^^^^^^^^^^^*********************************************************************************************^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         function focusCheck(dom, str) { $(dom).attr("class", "on").next("p").attr("class", "prompt ui-icons").text(str); }
         function success(dom) { $(dom).attr("class", "").next("p").attr("class", "").html('<img src="../images/gou.gif" />'); }

         var emailchecked = false;
         function emailBlur(dom) {
             var email = $(dom).val();
             if ($.trim(email).length <= 0) { $(dom).attr("class", "").val("").next("p").attr("class", ""); emailchecked = false; }
             else {
                 var reg = new RegExp("^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
                 if (reg.test($(dom).val())) {
                     $.ajax({
                         type: "POST",
                         url: "/App_Services/wsMember.asmx/CheckUserByEmail",
                         dataType: "text",
                         contentType: "application/json;utf-8",
                         data: "{email:'" + email.toLowerCase() + "'}",
                         timeout: 10000,
                         error: function (a, b, c) { emailchecked = true; $(dom).attr("class", "").next("p").attr("class", ""); },
                         success: function (msg) {
                             if (eval("(" + msg + ")")["d"]) {
                                 $(dom).attr("class", "wrong").next("p").attr("class", "red").text("Email地址已存在");
                                 emailchecked = false;
                             }
                             else {
                                 success(dom);
                                 emailchecked = true;
                             }
                         }
                     });
                 }
                 else {
                     $(dom).attr("class", "wrong").next("p").attr("class", "red").text("Email格式不正确");
                     emailchecked = false;
                 }
             }
         }

         var nicknamechecked = false;
         function nicknameblur(dom) {
             var nickname = $.trim($(dom).val());
             if (nickname.length <= 0) { $(dom).attr("class", "").val("").next("p").attr("class", "").text("用户名也可以作为您登录游龙网的帐号，大家以后就这样称呼您"); nicknamechecked = false; }
             else {
                 var regtest = new RegExp("^([\\u4e00-\\u9fa5]|\\w)*$");
                 var regunderline = new RegExp("_");
                 if (regtest.test(nickname) && regunderline.exec(nickname) == null) {
                     var regEng = new RegExp("\\w", "g");
                     var regCn = new RegExp("[\\u4e00-\\u9fa5]", "g");
                     var nicknamelength = 0;
                     var res;
                     while ((res = regEng.exec(nickname)) != null)
                         nicknamelength++;
                     while ((res = regCn.exec(nickname)) != null)
                         nicknamelength += 2;

                     if (nicknamelength <= 16 && nicknamelength >= 4) {
                         $.ajax({
                             type: "POST",
                             url: "/App_Services/wsMember.asmx/CheckUserByName",
                             dataType: "text",
                             contentType: "application/json;utf-8",
                             data: "{username:'" + nickname.toLowerCase() + "'}",
                             timeout: 10000,
                             error: function () { nicknamechecked = true; $(dom).attr("class", "").next("p").attr("class", ""); },
                             success: function (msg) {
                                 if (eval("(" + msg + ")")["d"]) {
                                     $(dom).attr("class", "wrong").next("p").attr("class", "red").text("用户名已存在");
                                     nicknamechecked = false;
                                 }
                                 else {
                                     success(dom);
                                     nicknamechecked = true;
                                 }
                             }
                         });
                     }
                     else {
                         $(dom).attr("class", "wrong").next("p").attr("class", "red").text("用户名长度必须是2-8个汉字或4-16个字符");
                         nicknamechecked = false;
                     }
                 }
                 else {
                     $(dom).attr("class", "wrong").next("p").attr("class", "red").text("用户名必须是大小写英文字母、中文、数字组成，长度2-8个汉字或4-16个字符");
                     nicknamechecked = false;
                 }
             }
         }

         var passwordchecked = false;
         function checkPassword(dom) {
             $("#passPower").hide();
             $(dom).next("p").show();
             var pass = $.trim($(dom).val());
             if (pass.length <= 0) { $(dom).attr("class", "").val("").next("p").attr("class", "").text("请输入您的帐号密码"); passwordchecked = false; }
             else {
                 var regtest = new RegExp("^(\\w)*$");
                 if (regtest.test(pass)) {
                     var regEng = new RegExp("\\w", "g");
                     var passLength = 0;
                     var res;
                     while ((res = regEng.exec(pass)) != null)
                         passLength++;

                     if (passLength <= 20 && passLength >= 6) {
                         success(dom);
                         if ($("#regRePassword").val().length > 0) {
                             reCheckPassword("#regRePassword");
                         }
                         passwordchecked = true;
                     }
                     else {
                         $(dom).attr("class", "wrong").next("p").attr("class", "red").text("密码长度必须是6-20个字符");
                         passwordchecked = false;
                     }
                 }
                 else {
                     $(dom).attr("class", "wrong").next("p").attr("class", "red").text("密码必须是大小写英文字母、数字组成、长度为6-20个字符");
                     passwordchecked = false;
                 }
             }
         }

         function passPower(dom) {
             var pass = $(dom).val().toLowerCase();
             var powerRank = 0;
             if (pass.length > 0) {
                 $(dom).next("p").hide();
                 if (pass.length > 8) powerRank++;
                 if (new RegExp("[0-9][a-z]|[a-z][0-9]").test(pass)) powerRank++;
                 if (new RegExp("[0-9]+[a-z]+[0-9]+[a-z]|[a-z]+[0-9]+[a-z]+[0-9]").test(pass)) powerRank++;
                 switch (powerRank) {
                     case 0: $("#passPower").attr("class", "rank").text("安全等级：低"); break;
                     case 1: $("#passPower").attr("class", "rank").text("安全等级：低"); break;
                     case 2: $("#passPower").attr("class", "rank mid").text("安全等级：中"); break;
                     case 3: $("#passPower").attr("class", "rank High").text("安全等级：高"); break;
                     default: $("#passPower").attr("class", "rank").text("安全等级：低"); break;
                 }
                 $("#passPower").css("display", "inline");
             }
             else {
                 $("#passPower").hide();
                 $(dom).next("p").show();
             }
         }

         var repasschecked = false;
         function reCheckPassword(dom) {
             var rePass = $.trim($(dom).val());
             if (rePass.length <= 0) {
                 $(dom).attr("class", "").next("p").attr("class", "").text("请再输入一次您的密码");
             } else {
                 if ($.trim($("#regPassword").val()) == rePass) {
                     success(dom);
                     repasschecked = true;
                 }
                 else {
                     $(dom).attr("class", "wrong").next("p").attr("class", "red").text("两次密码输入不一致，请重新输入");
                     repasschecked = false;
                 }
             }
         }

         var checkcodechecked = false;
         function checkCode(dom) {
             var checkCode = $.trim($(dom).val()).toLowerCase();
             if (checkCode == "") {
                 $(dom).attr("class", "verification").nextAll("p").hide(); checkcodechecked = false;
             }
             else {
                 $.ajax({
                     type: "POST",
                     url: "/ValidateCode.ashx?s=regCode&code=" + checkCode,
                     dataType: "text",
                     timeout: 10000,
                     error: function (a, b, c) { checkcodechecked = true; },
                     success: function (msg) {
                         if (msg == '0') {
                             checkcodechecked = false;
                             $(dom).attr("class", "verification wrong").nextAll("p").show();
                         }
                         else {
                             checkcodechecked = true;
                             $(dom).attr("class", "verification").nextAll("p").hide();
                         }
                     }
                 });
             }
         }

         function regSubmit() {
             if (!checkcodechecked) {
                 var checkCode = $.trim($("#regCheckCodeInput").val()).toLowerCase();
                 if (checkCode == "") {
                     $("#regCheckCodeInput").attr("class", "verification").nextAll("p").show(); checkcodechecked = false;
                 }
                 else {
                     $.ajax({
                         type: "POST",
                         url: "/ValidateCode.ashx?s=regCode&code=" + checkCode,
                         dataType: "text",
                         timeout: 5000,
                         error: function (a, b, c) { checkcodechecked = true; regSucSubmit(); },
                         success: function (msg) {
                             if (msg == '0') {
                                 checkcodechecked = false;
                                 $("#regCheckCodeInput").attr("class", "verification wrong").nextAll("p").show();
                             }
                             else {
                                 checkcodechecked = true;
                                 $("#regCheckCodeInput").attr("class", "verification").nextAll("p").hide();
                                 regSucSubmit();
                             }
                         }
                     });
                 }
             }
             else { regSucSubmit(); }
         }


         function regSucSubmit() {
             if ($.trim($("#regEmail").val()).length > 0) {
                 if ($.trim($("#regNickName").val()).length > 0) {
                     emailBlur($("#regEmail")); nicknameblur($("#regNickName")); checkPassword($("#regPassword")); reCheckPassword($("#regRePassword"));
                     if (emailchecked && nicknamechecked && passwordchecked && repasschecked && document.getElementById("regAgree").checked) {
                         $("form")[0].submit();
                     } else {
                         if (!document.getElementById("regAgree").checked)
                             alert("请仔细阅读注册协议并勾选同意复选框");
                     }
                 } else { $("#regNickName").attr("class", "wrong").next("p").attr("class", "red").text("请输入用户名"); }
             }
             else { $("#regEmail").attr("class", "wrong").next("p").attr("class", "red").text("请输入Email地址"); }
         }



         $(document).ready(function () {

             //document.forms[0].action = window.location;
             $("form").first().attr("action", window.location);

             $("#regCheckCodeInput").keydown(function (e) {
                 if (e.keyCode == 13) regSubmit();
             })
         });


        function showAjaxDialog(html) {
            var _dialog = $("#common_dialog_c");
            _dialog.html(html);
            _dialog.dialog({
                modal: true
            });       
        }